package com.bravo.article.controller;

import com.bravo.article.entity.Comment;
import com.bravo.article.service.CommentService;
import com.bravo.common.entity.Result;
import com.bravo.common.entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author: Yuyong
 * @create: 2019-07-29 11:33
 **/

@RestController
@CrossOrigin
@RequestMapping("/comment")
public class CommentController {

    @Autowired
    private CommentService commentService;

    @PostMapping
    public Result save(@RequestBody Comment comment){
        commentService.add(comment);
        return new Result(true, StatusCode.OK,"提交成功");
    }

    @GetMapping(value = "/article/{articleId}")
    public Result findByArticleId(@PathVariable String articleId){
        return new Result(true,StatusCode.OK,"查询成功",commentService.findByArticleId(articleId));
    }

}
